package community.service.impl;

import java.util.ArrayList;

import community.dal.DatabaseSession;
import community.dao.ICommentDao;
import community.dao.impl.CommentDao;
import community.domain.Comment;
import community.domain.DLAllComment;
import community.exception.DatabaseException;
import community.service.ICommentService;

public class CommentService implements ICommentService {

	ICommentDao commentDao = new CommentDao();
	@Override
	public ArrayList<Comment> getFirstLayerCommentByQuestionID( int questionid)
			throws DatabaseException {
		try (DatabaseSession databaseSession = new DatabaseSession()) {
			return commentDao.getFirstLayerCommentByQuestionID(databaseSession, questionid);
		}
	}

	@Override
	public ArrayList<Comment> getSecondLayerCommentByCommentID(int commentid)
			throws DatabaseException {
		try (DatabaseSession databaseSession = new DatabaseSession()) {
			return commentDao.getSecondLayerCommentByCommentID(databaseSession, commentid);
		}
	}

	@Override
	public ArrayList<DLAllComment> xkkdlgetFirstLayerCommentByQuestionID(int questionid) throws DatabaseException {
		try (DatabaseSession databaseSession = new DatabaseSession()) {
			return commentDao.xkkdlgetFirstLayerCommentByQuestionID(databaseSession, questionid);
		}
	}

	@Override
	public boolean addcomment(Comment c) throws DatabaseException {
		try (DatabaseSession databaseSession = new DatabaseSession()) {
			return commentDao.addcomment(databaseSession, c);
		}
	}

}
